package ro.ubbcluj.cs.damate.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ro.ubbcluj.cs.damate.persistence.entities.Team;
import ro.ubbcluj.cs.damate.persistence.repository.TeamRepository;

import java.util.List;

/**
 * @author Lóránd Fazakas (lorand)
 *         Date: 5/10/12
 *         Time: 9:49 PM
 */
@Service
public class TeamService {

    @Autowired
    private TeamRepository teamRepository;

    @Transactional
    public void create(Team transientTeam) {
        teamRepository.save(transientTeam);
    }

    @Transactional
    public void update(Team persistentTeam) {
        teamRepository.save(persistentTeam);
    }

    @Transactional
    public void delete(Team persistentTeam) {
        teamRepository.delete(persistentTeam);
    }

    public List<Team> findAll() {
        return teamRepository.findAllWithMembers();
    }
}
